import BaseCommand from "@/core/Frame/BaseClass/BaseCommand";

class OpenWidgetCommand extends BaseCommand {
  widgetsManager: any;
  constructor(params: any) {
    super();
    this.widgetsManager = params.widgetsManager;
  }

  execute(option: any) {
    const paramter = option.paramter;
    this.widgetsManager.activate({
      name: paramter.comName,
      styles: paramter.styles,
      comClass: paramter.comClass,
      _props: paramter._props,
      keyId: option.name + option.id
    });
  }

  isEnable(option: any) {
    const paramter = option.paramter;
    if (!paramter || paramter.comName == "") return true;
    return this.widgetsManager.hasActivateWidget(paramter.comName);
  }
}

export default OpenWidgetCommand;
